from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils import timezone

class User(AbstractUser):
    """自定义用户模型，扩展Django默认的用户模型"""
    # 保留默认字段：username, email, password
    
    # 新增字段
    avatar = models.ImageField(
        upload_to='avatars/', 
        blank=True, 
        null=True,
        verbose_name='头像'
    )
    bio = models.TextField(
        max_length=500, 
        blank=True, 
        verbose_name='个人简介'
    )
    created_at = models.DateTimeField(
        default=timezone.now,
        verbose_name='创建时间'
    )
    
    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'
        ordering = ['-created_at']
    
    def __str__(self):
        return self.username